# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.1386 -> 1.1387 # kernel/module.c 1.88 -> 1.89 # include/linux/module.h 1.66 -> 1.67 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 03/07/15 davidm@tiger.hpl.hp.com 1.1373.1.101 # ia64: Change per-CPU implementation so that __get_cpu_var() returns the # canonical address (l-value). To get the virtually mapped # alias (which is more efficient), use __ia64_per_cpu_var(). The # latter is safe only if the address of the l-value is never passed # to another CPU (i.e., not stored in any global place). # For extremely efficient, portable per-CPU variables, there is # now a new API local.h which was introduced by Rusty Russell. # To use this, declare a variable of type local_t as a per-CPU # variable and then use {__,}cpu_local_FOO() to manipulate such # variables. This patch also updated the atomic interface with # a 64-bit counter. # -------------------------------------------- # 03/07/15 rusty@rustcorp.com.au 1.1387 # [PATCH] Use local_t for module reference counts # # -------------------------------------------- # diff -Nru a/include/linux/module.h b/include/linux/module.h --- a/include/linux/module.h Wed Jul 16 00:39:27 2003 +++ b/include/linux/module.h Wed Jul 16 00:39:27 2003 @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -171,7 +172,7 @@ struct module_ref { - atomic_t count; + local_t count; } ____cacheline_aligned; enum module_state @@ -282,12 +283,6 @@ void __symbol_put(const char *symbol); #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) void symbol_put_addr(void *addr); - -/* We only need protection against local interrupts. */ -#ifndef __HAVE_ARCH_LOCAL_INC -#define local_inc(x) atomic_inc(x) -#define local_dec(x) atomic_dec(x) -#endif /* Sometimes we know we already have a refcount, and it's easier not to handle the error case (which only happens with rmmod --wait). */ diff -Nru a/kernel/module.c b/kernel/module.c --- a/kernel/module.c Wed Jul 16 00:39:27 2003 +++ b/kernel/module.c Wed Jul 16 00:39:27 2003 @@ -374,9 +374,9 @@ INIT_LIST_HEAD(&mod->modules_which_use_me); for (i = 0; i < NR_CPUS; i++) - atomic_set(&mod->ref[i].count, 0); + local_set(&mod->ref[i].count, 0); /* Hold reference count during initialization. */ - atomic_set(&mod->ref[smp_processor_id()].count, 1); + local_set(&mod->ref[smp_processor_id()].count, 1); /* Backwards compatibility macros put refcount during init. */ mod->waiter = current; } @@ -599,7 +599,7 @@ unsigned int i, total = 0; for (i = 0; i < NR_CPUS; i++) - total += atomic_read(&mod->ref[i].count); + total += local_read(&mod->ref[i].count); return total; } EXPORT_SYMBOL(module_refcount);